Skip to content

feat(observability): instrument event and websocket handlers with OTEL#661

Merged
cameri merged 3 commits into
cameri:mainfrom
Ferryx349:ADMIN-CONSOLE-2-metrics-handlers
Jul 5, 2026
Merged

feat(observability): instrument event and websocket handlers with OTEL#661
cameri merged 3 commits into
cameri:mainfrom
Ferryx349:ADMIN-CONSOLE-2-metrics-handlers

Conversation

@Ferryx349

@Ferryx349 Ferryx349 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Description

Wire OpenTelemetry counters into event publish paths and WebSocket lifecycle.

Related Issue

Fixes - #654

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

…L metrics

Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cb768e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls

coveralls commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 67.737% (+0.3%) from 67.417% — Ferryx349:ADMIN-CONSOLE-2-metrics-handlers into cameri:main

@Ferryx349 Ferryx349 requested a review from cameri June 30, 2026 11:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds OpenTelemetry metric instrumentation to key relay “event publish” OK responses and WebSocket connection lifecycle, building on the existing OTEL metrics bootstrap.

Changes:

  • Introduces a telemetry helper to increment accepted/rejected event counters and to track active WebSocket connections.
  • Routes event OK responses across event strategies and the main event handler through the new telemetry helper.
  • Emits WebSocket connection open/close metrics from the WebSocket adapter.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/telemetry/event-metrics.ts Adds helpers to increment event accepted/rejected counters and WebSocket connection up/down counter.
src/handlers/event-strategies/vanish-event-strategy.ts Switches OK responses to telemetry-wrapped command result.
src/handlers/event-strategies/timestamp-event-strategy.ts Switches accept/reject OK responses to telemetry-wrapped command result.
src/handlers/event-strategies/replaceable-event-strategy.ts Switches OK responses to telemetry-wrapped command result (incl. rejection path).
src/handlers/event-strategies/parameterized-replaceable-event-strategy.ts Switches OK responses to telemetry-wrapped command result.
src/handlers/event-strategies/group-event-strategy.ts Switches accept/reject OK responses to telemetry-wrapped command result.
src/handlers/event-strategies/gift-wrap-event-strategy.ts Switches accept/reject OK responses to telemetry-wrapped command result.
src/handlers/event-strategies/ephemeral-event-strategy.ts Switches OK response to telemetry-wrapped command result.
src/handlers/event-strategies/delete-event-strategy.ts Switches OK response to telemetry-wrapped command result.
src/handlers/event-strategies/default-event-strategy.ts Switches OK response to telemetry-wrapped command result.
src/handlers/event-message-handler.ts Switches all rejection OK responses to telemetry-wrapped command result; minor formatting change in recursion guard.
src/adapters/web-socket-adapter.ts Emits connection open/close metrics on connect/close.
.changeset/admin-metrics-handler-instrumentation.md Declares a minor release for the instrumentation feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

this.webSocket.emit(WebSocketAdapterEvent.Message, createCommandResult(event.id, false, 'error: '))
this.webSocket.emit(WebSocketAdapterEvent.Message, createEventCommandResult(event.id, false, 'error: '))
Comment on lines +17 to +23
export const recordWebsocketConnectionOpened = (): void => {
getRelayMetricInstruments().websocketConnections.add(1)
}

export const recordWebsocketConnectionClosed = (): void => {
getRelayMetricInstruments().websocketConnections.add(-1)
}
Comment on lines 34 to 67
@@ -63,13 +63,13 @@ export class EventMessageHandler implements IMessageHandler {
let reason = await this.isEventValid(event)
if (reason) {
logger('event %s rejected: %s', event.id, reason)
this.webSocket.emit(WebSocketAdapterEvent.Message, createCommandResult(event.id, false, reason))
this.webSocket.emit(WebSocketAdapterEvent.Message, createEventCommandResult(event.id, false, reason))
return
@cameri cameri merged commit 237b1a4 into cameri:main Jul 5, 2026
18 checks passed
@cameri

cameri commented Jul 5, 2026

Copy link
Copy Markdown
Owner

thank you!

@Ferryx349 Ferryx349 deleted the ADMIN-CONSOLE-2-metrics-handlers branch July 6, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants